﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Corporation.Project.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUD_AuditOperation",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    FunctionName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "执行的功能名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserId = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "用户编号")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Ip = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "访问IP")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OperationSystem = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "操作系统")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Browser = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "浏览器")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserAgent = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "当前访问用户代理")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Method = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: true, comment: "请求方法")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ContentType = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "请求内容类型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    QueryString = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "请求查询字符串")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Arguments = table.Column<string>(type: "longtext", nullable: true, comment: "请求参数")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ResultType = table.Column<int>(type: "int", nullable: false, comment: "操作结果(Ajax结果类型：[200]成功；[400]错误；[401]未登录；[403]已登录但权限不足；[404]资源未找到；[405]不允许；[415]不支持；[423]资源被锁定；[500]服务器内部错误；[501]功能未实现)"),
                    Message = table.Column<string>(type: "VARCHAR(3072)", maxLength: 3072, nullable: true, comment: "消息")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ResultData = table.Column<string>(type: "longtext", nullable: true, comment: "结果数据")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Elapsed = table.Column<int>(type: "int", nullable: false, comment: "执行耗时（毫秒）"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "信息添加时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUD_AuditOperation", x => x.Id);
                },
                comment: "审计操作信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_EntityInfo",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "实体名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TypeName = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "实体类型名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DbSchema = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: false, comment: "数据库架构")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DbObjName = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: false, comment: "数据库对象名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DbObjType = table.Column<int>(type: "int", nullable: false, comment: "数据库对象类型(数据库对象类型：[1]数据表；[2]数据视图；[3]函数；[4]存储过程；[5]触发器)"),
                    AuditEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: " 启用数据审计"),
                    EventEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "启用数据事件"),
                    PropertyJson = table.Column<string>(type: "longtext", nullable: true, comment: "实体属性信息Json字符串")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DataVersion = table.Column<long>(type: "bigint", nullable: false, comment: "数据版本")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_EntityInfo", x => x.Id);
                },
                comment: "实体信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_EntityRole",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    RoleId = table.Column<long>(type: "bigint", nullable: false, comment: "角色编号"),
                    EntityId = table.Column<long>(type: "bigint", nullable: false, comment: "数据编号"),
                    Operation = table.Column<int>(type: "int", nullable: false, comment: "数据权限操作(数据权限操作：[1]读取；[3]更新；[4]删除)"),
                    FilterGroupJson = table.Column<string>(type: "longtext", nullable: true, comment: "过滤条件组")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DataVersion = table.Column<long>(type: "bigint", nullable: false, comment: "数据版本")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_EntityRole", x => x.Id);
                },
                comment: "数据角色信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_EntityUser",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    EntityId = table.Column<long>(type: "bigint", nullable: false, comment: "数据编号"),
                    Operation = table.Column<int>(type: "int", nullable: false, comment: "数据权限操作(数据权限操作：[1]读取；[3]更新；[4]删除)"),
                    FilterGroupJson = table.Column<string>(type: "longtext", nullable: true, comment: "过滤条件组")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DataVersion = table.Column<long>(type: "bigint", nullable: false, comment: "数据版本")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_EntityUser", x => x.Id);
                },
                comment: "数据用户信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_Function",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "功能名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Area = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "区域")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Controller = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "控制器")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Action = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "功能")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsController = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否控制器"),
                    IsAjax = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否Ajax功能"),
                    AccessType = table.Column<int>(type: "int", nullable: false, comment: "访问类型(功能访问类型：[1]匿名访问；[2]登录访问；[3]角色访问)"),
                    IsAccessTypeChanged = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "访问类型是否更改"),
                    AuditOperationEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否操作审计"),
                    AuditEntityEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否数据审计"),
                    CacheExpirationSeconds = table.Column<int>(type: "int", nullable: false, comment: "数据缓存秒数"),
                    IsCacheSliding = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否相对过期时间"),
                    IsSlaveDatabase = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否从库"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DataVersion = table.Column<long>(type: "bigint", nullable: false, comment: "数据版本")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_Function", x => x.Id);
                },
                comment: "功能信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_Module",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Code = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: false, comment: "模块编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "模块名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FullCode = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "模块完整编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FullName = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "模块完整名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "模块描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderNo = table.Column<decimal>(type: "decimal(22,10)", precision: 22, scale: 10, nullable: false, comment: "顺序编号"),
                    TreePathString = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "节点树形路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentId = table.Column<long>(type: "bigint", nullable: true, comment: "父模块编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_Module", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Module_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AUZ_Module",
                        principalColumn: "Id");
                },
                comment: "模块信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_Organization",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Code = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: false, comment: "组织机构编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Type = table.Column<int>(type: "int", nullable: false, comment: "组织机构类型(组织机构类型：[1]虚拟组织；[2]法人组织；[3]部门组织)"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "组织机构名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NormalizedName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "标准化名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "组织机构描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderNo = table.Column<decimal>(type: "decimal(22,10)", precision: 22, scale: 10, nullable: false, comment: "顺序编号"),
                    TreePathString = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "节点树形路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentId = table.Column<long>(type: "bigint", nullable: true, comment: "父组织机构编号"),
                    EnableLogin = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "启用登陆"),
                    IsDefault = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "默认组织机构"),
                    IsSystem = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否系统组织机构"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdaterId = table.Column<long>(type: "bigint", nullable: true, comment: "更新者编号"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DeletedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_Organization", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Organization_ParentId",
                        column: x => x.ParentId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id");
                },
                comment: "组织机构信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_Role",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "角色名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NormalizedName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "标准化名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "角色描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsAdmin = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否管理员角色"),
                    IsDefault = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否默认角色"),
                    IsSystem = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否系统角色"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdaterId = table.Column<long>(type: "bigint", nullable: true, comment: "更新者编号"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DeletedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_Role", x => x.Id);
                },
                comment: "角色信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_User",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "用户名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NormalizedUserName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "标准化用户名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NickName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "用户昵称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Email = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "电子邮箱")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NormalizeEmail = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "标准化电子邮箱")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "邮箱确认"),
                    PhoneNumber = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: true, comment: "手机号码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhoneConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "手机确认"),
                    PasswordHash = table.Column<string>(type: "longtext", nullable: true, comment: "密码哈希值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "双因子身份验证"),
                    LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true, comment: "锁定时间"),
                    LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否登录锁"),
                    AccessFailedCount = table.Column<int>(type: "int", nullable: false, comment: "登录失败次数"),
                    SecurityStamp = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "安全标识")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    IsSystem = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否系统用户"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    DeletedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "删除时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_User", x => x.Id);
                },
                comment: "用户信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MSG_Message",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    BaseType = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "基本对象")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    BaseId = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: true, comment: "基本对象编号")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Method = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "方法名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Icon = table.Column<string>(type: "longtext", nullable: true, comment: "消息图标")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MessageType = table.Column<int>(type: "int", nullable: false, comment: "消息类型(消息类型：[1]文本消息；[2]图片消息；[3]语音消息；[4]视频消息；[5]文件消息；[6]图文消息；[7]数据消息)"),
                    MessageLevel = table.Column<int>(type: "int", nullable: false, comment: "消息级别(消息级别：[1]跟踪消息；[2]信息消息；[3]成功消息；[4]警告消息；[5]错误消息；[6]异常消息)"),
                    Title = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Content = table.Column<string>(type: "VARCHAR(3072)", maxLength: 3072, nullable: true, comment: "内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Payload = table.Column<string>(type: "longtext", nullable: true, comment: "数据体")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSystem = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "系统消息"),
                    SenderId = table.Column<long>(type: "bigint", nullable: true, comment: "发送者编号"),
                    IsSent = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否已发送"),
                    SendTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "发送时间"),
                    SendWays = table.Column<string>(type: "longtext", nullable: true, comment: "发送方式：1-Internal(内部消息)、2-Email(邮件消息)、99-OAuth2(第三方平台消息)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToUsers = table.Column<string>(type: "longtext", nullable: true, comment: "发送至用户")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToOrganizations = table.Column<string>(type: "longtext", nullable: true, comment: "发送至组织机构")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToRoles = table.Column<string>(type: "longtext", nullable: true, comment: "发送至角色")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    StorageDays = table.Column<int>(type: "int", nullable: false, comment: "存储天数(0-365,0表示永久存储)"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdaterId = table.Column<long>(type: "bigint", nullable: true, comment: "更新者编号"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_Message", x => x.Id);
                },
                comment: "消息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MSG_TemplateMessage",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Method = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "方法名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Icon = table.Column<string>(type: "longtext", nullable: true, comment: "消息图标")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MessageType = table.Column<int>(type: "int", nullable: false, comment: "消息类型(消息类型：[1]文本消息；[2]图片消息；[3]语音消息；[4]视频消息；[5]文件消息；[6]图文消息；[7]数据消息)"),
                    MessageLevel = table.Column<int>(type: "int", nullable: false, comment: "消息级别(消息级别：[1]跟踪消息；[2]信息消息；[3]成功消息；[4]警告消息；[5]错误消息；[6]异常消息)"),
                    Title = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Content = table.Column<string>(type: "VARCHAR(3072)", maxLength: 3072, nullable: true, comment: "内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Payload = table.Column<string>(type: "longtext", nullable: true, comment: "数据体")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SendWays = table.Column<string>(type: "longtext", nullable: true, comment: "发送方式：1-Internal(内部消息)、2-Email(邮件消息)、99-OAuth2(第三方平台消息)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToUsers = table.Column<string>(type: "longtext", nullable: true, comment: "发送至用户")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToOrganizations = table.Column<string>(type: "longtext", nullable: true, comment: "发送至组织机构")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ToRoles = table.Column<string>(type: "longtext", nullable: true, comment: "发送至角色")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NextSendTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "下次发送时间"),
                    CronExpression = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "Cron表达式")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Enabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否启用"),
                    StorageDays = table.Column<int>(type: "int", nullable: false, comment: "存储天数(0-365,0表示永久存储)"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdaterId = table.Column<long>(type: "bigint", nullable: true, comment: "更新者编号"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间"),
                    DataVersion = table.Column<long>(type: "bigint", nullable: false, comment: "数据版本")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_TemplateMessage", x => x.Id);
                },
                comment: "模板消息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Project_Article",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "编号", collation: "ascii_general_ci"),
                    Type = table.Column<int>(type: "int", nullable: false, comment: "类型(Corporation.Project.Datas.ArticleType：[0]轮播；[1]资讯)"),
                    ImageBase64 = table.Column<string>(type: "TEXT", maxLength: 4096, nullable: true, comment: "图片Base64字符串")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ImageUrl = table.Column<string>(type: "varchar(3072)", maxLength: 3072, nullable: true, comment: "单图片Url路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ImageUrls = table.Column<string>(type: "varchar(4096)", maxLength: 4096, nullable: true, comment: "多图片Url路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileUrls = table.Column<string>(type: "longtext", nullable: true, comment: "文件路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Title = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "标题")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderNo = table.Column<int>(type: "int", nullable: false, comment: "排序号"),
                    Content = table.Column<string>(type: "TEXT", maxLength: 4096, nullable: true, comment: "文章内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Project_Article", x => x.Id);
                },
                comment: "文章信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SMS_VerifyCode",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Provider = table.Column<int>(type: "int", nullable: false, comment: "服务提供商(短信服务提供商：[1]阿里云；[2]逸峰信盈通)"),
                    SignName = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "短信签名名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TemplateCode = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "短信模板ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    BizId = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "发送回执ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RequestId = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "请求ID")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OutId = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "外部流水扩展字段")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhoneNumber = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: false, comment: "手机号码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SendDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "发送日期"),
                    ReceiveDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "接收日期"),
                    Message = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "信息内容")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    VerifyCode = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: false, comment: "验证码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ExpireMins = table.Column<decimal>(type: "decimal(22,10)", precision: 22, scale: 10, nullable: false, comment: "有效期分钟数"),
                    Verified = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "已验证"),
                    VerifiedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "验证时间"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SMS_VerifyCode", x => x.Id);
                },
                comment: "验证码短信记录")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_Dict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "编号", collation: "ascii_general_ci"),
                    Code = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: false, comment: "字典编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "字典名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "字典备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_Dict", x => x.Id);
                },
                comment: "字典")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_File",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    FileName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileExtension = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: false, comment: "文件扩展名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Size = table.Column<long>(type: "bigint", nullable: false, comment: "文件大小(bytes)"),
                    SerializedName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件序列化名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SHA1 = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件SHA1值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MD5 = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件MD5值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhysicalPath = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "物理存储路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RequestPath = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "文件请求路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Version = table.Column<long>(type: "bigint", nullable: false, comment: "文件版本"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdaterId = table.Column<long>(type: "bigint", nullable: true, comment: "更新者编号"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_File", x => x.Id);
                },
                comment: "文件")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_FileActionRecord",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    FileId = table.Column<long>(type: "bigint", nullable: false, comment: "文件ID"),
                    ActionType = table.Column<int>(type: "int", nullable: false, comment: "记录类型(文件记录类型：[1]上传；[2]下载；[3]删除；[4]更新；[5]复制；[6]迁移)"),
                    Version = table.Column<long>(type: "bigint", nullable: false, comment: "文件版本"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_FileActionRecord", x => x.Id);
                },
                comment: "文件操作记录")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_FileSaveRecord",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    FileId = table.Column<long>(type: "bigint", nullable: false, comment: "文件ID"),
                    FileName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FileExtension = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: false, comment: "文件扩展名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SHA1 = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件SHA1值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MD5 = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件MD5值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Size = table.Column<long>(type: "bigint", nullable: false, comment: "文件大小(bytes)"),
                    SerializedName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件序列化名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PhysicalPath = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "物理存储路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RequestPath = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "文件请求路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Version = table.Column<long>(type: "bigint", nullable: false, comment: "文件版本"),
                    FileByte = table.Column<byte[]>(type: "longblob", nullable: false, comment: "文件字节"),
                    CreatorId = table.Column<long>(type: "bigint", nullable: true, comment: "创建者编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_FileSaveRecord", x => x.Id);
                },
                comment: "文件存档记录")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_KeyValue",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    Key = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "数据键名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ValueJson = table.Column<string>(type: "longtext", nullable: false, comment: "数据值JSON")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ValueType = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "数据值类型名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Display = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "显示名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderNo = table.Column<decimal>(type: "decimal(22,10)", precision: 22, scale: 10, nullable: false, comment: "顺序编号"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_KeyValue", x => x.Id);
                },
                comment: "键值数据")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUD_AuditEntity",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    OperationId = table.Column<long>(type: "bigint", nullable: false, comment: "所属审计操作编号"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "实体名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TypeName = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "类型名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    EntityKey = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "数据编号")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OperateType = table.Column<int>(type: "int", nullable: false, comment: "操作类型(操作类型：[1]查询；[2]新增；[3]更新；[4]删除)")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUD_AuditEntity", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AuditEntity_OperationId",
                        column: x => x.OperationId,
                        principalTable: "AUD_AuditOperation",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "审计实体信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_ModuleFunction",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    ModuleId = table.Column<long>(type: "bigint", nullable: false, comment: "模块编号"),
                    FunctionId = table.Column<long>(type: "bigint", nullable: false, comment: "功能编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_ModuleFunction", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ModuleFunction_ModuleId",
                        column: x => x.ModuleId,
                        principalTable: "AUZ_Module",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "模块功能信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_ModuleRole",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    ModuleId = table.Column<long>(type: "bigint", nullable: false, comment: "模块编号"),
                    RoleId = table.Column<long>(type: "bigint", nullable: false, comment: "角色编号"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_ModuleRole", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ModuleRole_ModuleId",
                        column: x => x.ModuleId,
                        principalTable: "AUZ_Module",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "角色模块信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUZ_ModuleUser",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    ModuleId = table.Column<long>(type: "bigint", nullable: false, comment: "模块编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    Disabled = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否禁用"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUZ_ModuleUser", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ModuleUser_ModuleId",
                        column: x => x.ModuleId,
                        principalTable: "AUZ_Module",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户模块信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_OrganizationClaim",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false, comment: "组织机构编号"),
                    ClaimType = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "声明类型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClaimValue = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "声明值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_OrganizationClaim", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrganizationClaim_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "组织机构声明信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_OrganizationDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false, comment: "组织机构编号"),
                    NameFrgn = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "组织机构名称(外文)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "地址")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    AddressFrgn = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "地址(外文)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PrintHeader = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "打印抬头")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PrintHeaderFrgn = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "打印抬头(外文)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ReptName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "报表名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ReptNameFrgn = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "报表名称(外文)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_OrganizationDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrganizationDetail_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "组织机构详细信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_OrganizationPortfolio",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false, comment: "组织机构编号"),
                    Avatar = table.Column<string>(type: "longtext", nullable: true, comment: "电子头像")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Signature = table.Column<string>(type: "longtext", nullable: true, comment: "电子签名")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_OrganizationPortfolio", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OrganizationPortfolio_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "组织机构证照")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_RoleClaim",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    RoleId = table.Column<long>(type: "bigint", nullable: false, comment: "角色编号"),
                    ClaimType = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "声明类型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClaimValue = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "声明值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_RoleClaim", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RoleClaim_RoleId",
                        column: x => x.RoleId,
                        principalTable: "IDT_Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "角色声明信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_RoleOrganization",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    RoleId = table.Column<long>(type: "bigint", nullable: false, comment: "角色编号"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false, comment: "组织机构编号"),
                    Administrator = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "机构管理员"),
                    Leader = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "机构经理"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_RoleOrganization", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RoleOrganization_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_RoleOrganization_RoleId",
                        column: x => x.RoleId,
                        principalTable: "IDT_Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "角色组织机构信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_LoginLog",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    Ip = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "登录IP")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UserAgent = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "用户代理")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    LogoutTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "退出时间"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_LoginLog", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LoginLog_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户登录日志")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserClaim",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    ClaimType = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "声明类型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ClaimValue = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "声明值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserClaim", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserClaim_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户声明信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserDetail",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    RegisterIp = table.Column<string>(type: "VARCHAR(128)", maxLength: 128, nullable: true, comment: "注册IP")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    RegisterType = table.Column<int>(type: "int", nullable: false, comment: "注册类型(用户注册类型：[1]电子邮箱；[2]手机号码；[3]二者皆有；[4]二者皆无)"),
                    Gender = table.Column<int>(type: "int", nullable: false, comment: "性别(性别：[0]未知；[1]男；[2]女)"),
                    Birthday = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "生日"),
                    BloodType = table.Column<string>(type: "VARCHAR(64)", maxLength: 64, nullable: true, comment: "血型")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Tag = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "标签")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Title = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "头衔")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: true, comment: "地址")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Profile = table.Column<string>(type: "VARCHAR(1024)", maxLength: 1024, nullable: true, comment: "简介")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Sign = table.Column<string>(type: "longtext", nullable: true, comment: "个性签名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    HomePath = table.Column<string>(type: "VARCHAR(3072)", maxLength: 3072, nullable: true, comment: "主页")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserDetail", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserDetail_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户详细信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserLogin",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    LoginProvider = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "登录提供程序")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ProviderKey = table.Column<string>(type: "VARCHAR(512)", maxLength: 512, nullable: false, comment: "登录唯一标识")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DisplayName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "显示名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Avatar = table.Column<string>(type: "longtext", nullable: true, comment: "头像")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserLogin", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserLogin_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户登录信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserOrganization",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    OrganizationId = table.Column<long>(type: "bigint", nullable: false, comment: "组织机构编号"),
                    Administrator = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "机构管理员"),
                    Leader = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "机构经理"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserOrganization", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserOrganization_OrganizationId",
                        column: x => x.OrganizationId,
                        principalTable: "IDT_Organization",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserOrganization_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户组织机构信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserPortfolio",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    Avatar = table.Column<string>(type: "longtext", nullable: true, comment: "电子头像")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Signature = table.Column<string>(type: "longtext", nullable: true, comment: "电子签名")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserPortfolio", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserPortfolio_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户证照")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserRole",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    RoleId = table.Column<long>(type: "bigint", nullable: false, comment: "角色编号"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserRole", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserRole_RoleId",
                        column: x => x.RoleId,
                        principalTable: "IDT_Role",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_UserRole_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户角色信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "IDT_UserToken",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    UserId = table.Column<long>(type: "bigint", nullable: false, comment: "用户编号"),
                    LoginProvider = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "登录提供者")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "令牌名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Value = table.Column<string>(type: "longtext", nullable: false, comment: "令牌值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IDT_UserToken", x => x.Id);
                    table.ForeignKey(
                        name: "FK_UserToken_UserId",
                        column: x => x.UserId,
                        principalTable: "IDT_User",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "用户的身份认证令牌")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "MSG_MessageReceiver",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    MessageId = table.Column<long>(type: "bigint", nullable: false, comment: "消息编号"),
                    ReceiverId = table.Column<long>(type: "bigint", nullable: false, comment: "接收者编号"),
                    SendWays = table.Column<string>(type: "longtext", nullable: true, comment: "发送方式：1-Internal(内部消息)、2-Email(邮件消息)、99-OAuth2(第三方平台消息)")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    LastReadTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "阅读时间"),
                    LastReadWay = table.Column<int>(type: "int", nullable: true, comment: "阅读方式"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_MessageReceiver", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MessageReceiver_MessageId",
                        column: x => x.MessageId,
                        principalTable: "MSG_Message",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "消息接收者")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "SYS_DictEntry",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "编号", collation: "ascii_general_ci"),
                    DictId = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "字典编码", collation: "ascii_general_ci"),
                    CodeName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "编码名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CodeValue = table.Column<int>(type: "int", nullable: false, comment: "编码值"),
                    Remark = table.Column<string>(type: "VARCHAR(2048)", maxLength: 2048, nullable: true, comment: "备注")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OrderNo = table.Column<int>(type: "int", nullable: false, comment: "排序号"),
                    IsLocked = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否锁定"),
                    CreatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "创建时间"),
                    UpdatedTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "更新时间")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SYS_DictEntry", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DictEntry_DictId",
                        column: x => x.DictId,
                        principalTable: "SYS_Dict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "字典项")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "AUD_AuditProperty",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", maxLength: 128, nullable: false, comment: "编号"),
                    AuditEntityId = table.Column<long>(type: "bigint", nullable: false, comment: "所属审计实体编号"),
                    DisplayName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "显示名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    FieldName = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: false, comment: "字段")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OriginalValue = table.Column<string>(type: "longtext", nullable: true, comment: "旧值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NewValue = table.Column<string>(type: "longtext", nullable: true, comment: "新值")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DataType = table.Column<string>(type: "VARCHAR(256)", maxLength: 256, nullable: true, comment: "数据类型")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AUD_AuditProperty", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AuditProperty_AuditEntityId",
                        column: x => x.AuditEntityId,
                        principalTable: "AUD_AuditEntity",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "审计实体属性信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_AuditEntity_OperationId",
                table: "AUD_AuditEntity",
                column: "OperationId");

            migrationBuilder.CreateIndex(
                name: "IX_AuditOperation_CreatedTime",
                table: "AUD_AuditOperation",
                column: "CreatedTime");

            migrationBuilder.CreateIndex(
                name: "IX_AuditOperation_FunctionName",
                table: "AUD_AuditOperation",
                column: "FunctionName");

            migrationBuilder.CreateIndex(
                name: "IX_AuditOperation_ResultType",
                table: "AUD_AuditOperation",
                column: "ResultType");

            migrationBuilder.CreateIndex(
                name: "IX_AuditProperty_AuditEntityId",
                table: "AUD_AuditProperty",
                column: "AuditEntityId");

            migrationBuilder.CreateIndex(
                name: "IX_EntityInfo_Name",
                table: "AUZ_EntityInfo",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IDX_EntityRole_EntityRoleOperation",
                table: "AUZ_EntityRole",
                columns: new[] { "EntityId", "RoleId", "Operation" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_EntityUser_EntityUserOperation",
                table: "AUZ_EntityUser",
                columns: new[] { "EntityId", "UserId", "Operation" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_Function_AreaControllerAction",
                table: "AUZ_Function",
                columns: new[] { "Area", "Controller", "Action" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Function_Name",
                table: "AUZ_Function",
                column: "Name");

            migrationBuilder.CreateIndex(
                name: "IDX_Module_Code",
                table: "AUZ_Module",
                columns: new[] { "ParentId", "Code" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_Module_Name",
                table: "AUZ_Module",
                columns: new[] { "ParentId", "Name" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_ModuleFunction_ModuleFunctionId",
                table: "AUZ_ModuleFunction",
                columns: new[] { "ModuleId", "FunctionId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_ModuleRole_ModuleRoleId",
                table: "AUZ_ModuleRole",
                columns: new[] { "ModuleId", "RoleId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_ModuleUser_ModuleUserId",
                table: "AUZ_ModuleUser",
                columns: new[] { "ModuleId", "UserId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_LoginLog_UserId",
                table: "IDT_LoginLog",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IDX_Organization_Code",
                table: "IDT_Organization",
                columns: new[] { "Code", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_Organization_Name",
                table: "IDT_Organization",
                columns: new[] { "Name", "ParentId", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Organization_ParentId",
                table: "IDT_Organization",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_IDT_OrganizationClaim_OrganizationId",
                table: "IDT_OrganizationClaim",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_IDT_OrganizationDetail_OrganizationId",
                table: "IDT_OrganizationDetail",
                column: "OrganizationId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_OrganizationPortfolio_OrganizationId",
                table: "IDT_OrganizationPortfolio",
                column: "OrganizationId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_Role_Name",
                table: "IDT_Role",
                columns: new[] { "NormalizedName", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_RoleClaim_RoleId",
                table: "IDT_RoleClaim",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IDX_RoleOrganization_Ids",
                table: "IDT_RoleOrganization",
                columns: new[] { "RoleId", "OrganizationId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_RoleOrganization_OrganizationId",
                table: "IDT_RoleOrganization",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IDX_User_Email",
                table: "IDT_User",
                columns: new[] { "UserName", "Email", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_User_PhoneNumber",
                table: "IDT_User",
                columns: new[] { "UserName", "PhoneNumber", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_User_UserName",
                table: "IDT_User",
                columns: new[] { "UserName", "DeletedTime" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_User_NickName",
                table: "IDT_User",
                column: "NickName");

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserClaim_UserId",
                table: "IDT_UserClaim",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserDetail_UserId",
                table: "IDT_UserDetail",
                column: "UserId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_UserLogin_Provider",
                table: "IDT_UserLogin",
                columns: new[] { "LoginProvider", "ProviderKey" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserLogin_UserId",
                table: "IDT_UserLogin",
                column: "UserId");

            migrationBuilder.CreateIndex(
                name: "IDX_UserOrganization_Ids",
                table: "IDT_UserOrganization",
                columns: new[] { "UserId", "OrganizationId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserOrganization_OrganizationId",
                table: "IDT_UserOrganization",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserPortfolio_UserId",
                table: "IDT_UserPortfolio",
                column: "UserId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_UserRole_Ids",
                table: "IDT_UserRole",
                columns: new[] { "UserId", "RoleId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_IDT_UserRole_RoleId",
                table: "IDT_UserRole",
                column: "RoleId");

            migrationBuilder.CreateIndex(
                name: "IDX_UserToken_Token",
                table: "IDT_UserToken",
                columns: new[] { "UserId", "LoginProvider", "Name" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Message_BaseTypeId",
                table: "MSG_Message",
                columns: new[] { "BaseType", "BaseId" });

            migrationBuilder.CreateIndex(
                name: "IX_Message_IsSent",
                table: "MSG_Message",
                column: "IsSent");

            migrationBuilder.CreateIndex(
                name: "IX_Message_Method",
                table: "MSG_Message",
                column: "Method");

            migrationBuilder.CreateIndex(
                name: "IX_Message_SenderId",
                table: "MSG_Message",
                column: "SenderId");

            migrationBuilder.CreateIndex(
                name: "IDX_MessageReceiver_MessageReceiverId",
                table: "MSG_MessageReceiver",
                columns: new[] { "MessageId", "ReceiverId" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_MessageReceiver_LastReadTime",
                table: "MSG_MessageReceiver",
                column: "LastReadTime");

            migrationBuilder.CreateIndex(
                name: "IX_TemplateMessage_Method",
                table: "MSG_TemplateMessage",
                column: "Method");

            migrationBuilder.CreateIndex(
                name: "IDX_Article_TypeTitle",
                table: "Project_Article",
                columns: new[] { "Type", "Title" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_VerifyCode_PhoneBiz",
                table: "SMS_VerifyCode",
                columns: new[] { "PhoneNumber", "Provider", "BizId", "VerifyCode", "Verified" });

            migrationBuilder.CreateIndex(
                name: "IX_VerifyCode_SendDate",
                table: "SMS_VerifyCode",
                column: "SendDate");

            migrationBuilder.CreateIndex(
                name: "IDX_Dict_Code",
                table: "SYS_Dict",
                column: "Code",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IDX_DictEntry_DictIdCodeValue",
                table: "SYS_DictEntry",
                columns: new[] { "DictId", "CodeValue" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_File_FileExtension",
                table: "SYS_File",
                column: "FileExtension");

            migrationBuilder.CreateIndex(
                name: "IX_File_FileName",
                table: "SYS_File",
                column: "FileName");

            migrationBuilder.CreateIndex(
                name: "IX_File_HashMD5",
                table: "SYS_File",
                columns: new[] { "SHA1", "MD5" });

            migrationBuilder.CreateIndex(
                name: "IX_FileActionRecord_ActionType",
                table: "SYS_FileActionRecord",
                column: "ActionType");

            migrationBuilder.CreateIndex(
                name: "IX_FileActionRecord_FileId",
                table: "SYS_FileActionRecord",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_FileSaveRecord_FileId",
                table: "SYS_FileSaveRecord",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_FileSaveRecord_HashMD5",
                table: "SYS_FileSaveRecord",
                columns: new[] { "SHA1", "MD5" });

            migrationBuilder.CreateIndex(
                name: "IDX_KeyValue_Key",
                table: "SYS_KeyValue",
                column: "Key",
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AUD_AuditProperty");

            migrationBuilder.DropTable(
                name: "AUZ_EntityInfo");

            migrationBuilder.DropTable(
                name: "AUZ_EntityRole");

            migrationBuilder.DropTable(
                name: "AUZ_EntityUser");

            migrationBuilder.DropTable(
                name: "AUZ_Function");

            migrationBuilder.DropTable(
                name: "AUZ_ModuleFunction");

            migrationBuilder.DropTable(
                name: "AUZ_ModuleRole");

            migrationBuilder.DropTable(
                name: "AUZ_ModuleUser");

            migrationBuilder.DropTable(
                name: "IDT_LoginLog");

            migrationBuilder.DropTable(
                name: "IDT_OrganizationClaim");

            migrationBuilder.DropTable(
                name: "IDT_OrganizationDetail");

            migrationBuilder.DropTable(
                name: "IDT_OrganizationPortfolio");

            migrationBuilder.DropTable(
                name: "IDT_RoleClaim");

            migrationBuilder.DropTable(
                name: "IDT_RoleOrganization");

            migrationBuilder.DropTable(
                name: "IDT_UserClaim");

            migrationBuilder.DropTable(
                name: "IDT_UserDetail");

            migrationBuilder.DropTable(
                name: "IDT_UserLogin");

            migrationBuilder.DropTable(
                name: "IDT_UserOrganization");

            migrationBuilder.DropTable(
                name: "IDT_UserPortfolio");

            migrationBuilder.DropTable(
                name: "IDT_UserRole");

            migrationBuilder.DropTable(
                name: "IDT_UserToken");

            migrationBuilder.DropTable(
                name: "MSG_MessageReceiver");

            migrationBuilder.DropTable(
                name: "MSG_TemplateMessage");

            migrationBuilder.DropTable(
                name: "Project_Article");

            migrationBuilder.DropTable(
                name: "SMS_VerifyCode");

            migrationBuilder.DropTable(
                name: "SYS_DictEntry");

            migrationBuilder.DropTable(
                name: "SYS_File");

            migrationBuilder.DropTable(
                name: "SYS_FileActionRecord");

            migrationBuilder.DropTable(
                name: "SYS_FileSaveRecord");

            migrationBuilder.DropTable(
                name: "SYS_KeyValue");

            migrationBuilder.DropTable(
                name: "AUD_AuditEntity");

            migrationBuilder.DropTable(
                name: "AUZ_Module");

            migrationBuilder.DropTable(
                name: "IDT_Organization");

            migrationBuilder.DropTable(
                name: "IDT_Role");

            migrationBuilder.DropTable(
                name: "IDT_User");

            migrationBuilder.DropTable(
                name: "MSG_Message");

            migrationBuilder.DropTable(
                name: "SYS_Dict");

            migrationBuilder.DropTable(
                name: "AUD_AuditOperation");
        }
    }
}
